{extend name="public/base" /}
{block name="style"}<link href="__LIB__/fileinput/css/fileinput.min.css" rel="stylesheet" /> {/block}
 {block name="body"}
 <div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li><strong>站点配置</strong></li>
	</ol>
</div>
<div class="row">
	<div class="col-sm-12">
		<div class="ibox float-e-margins">
			{include file="agent/top"}
			<div class="ibox-content">
				<form id="myForm" class="form-horizontal m-t" method="post" action="{:url('index')}">
				<input type="hidden" name="id" value="{$ad.id}" />
				<!--店铺基本信息-->
				<div class="form-group">
					<label class="col-sm-2 control-label">名称：</label>
					<div class="input-group col-sm-4">
						<input type="text" id="store_name" name="store_name" value="{$ad.store_name}"  class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">地理位置：</label>
					<div class="input-group col-sm-10">
						<div class="row">
                                <div class="col-md-2">
                                    <input type="text" id="longitude" name="longitude" value="{$ad.longitude}" placeholder="所在经度" class="form-control">
                                </div>
                                <div class="col-md-2">
                                    <input type="text" id="latitude" name="latitude" value="{$ad.latitude}" placeholder="所在纬度" class="form-control">
                                </div>
                                <div class="col-md-6">
                                	<div class="input-group">
                                    <input type="text" id="address" name="address" value="{$ad.address}" placeholder="店铺位置" class="form-control">
                                    <span class="input-group-btn"> <button type="button" onclick="show_map()" class="btn btn-primary">选择坐标
                                    </button> </span>
                           		 </div>
                                    
                                </div>
                        </div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">首页链接：</label>
					<div class="input-group col-sm-4">
						<img src="{$code_url}" width="140px"/>
						<input type="text" name="" class="form-control" value="{$url}" readonly/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">LOGO：</label>
					<div class="input-group col-sm-4">
						<input type="hidden" id="store_logo" name="store_logo"  value="{$ad.store_logo}"/>
						<input id="upload" name="upload" type="file" />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-sm-2 control-label">电话：</label>
					<div class="input-group col-sm-4">
						<input type="text" id="store_tel" name="store_tel" value="{$ad.store_tel}"  class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">店铺性质：</label>
					<div class="input-group col-sm-4">
						<select class="form-control" name="store_property">
							<option>请选择店铺性质</option>
							<option value="1" {if  $ad.store_property == 1}selected{/if}>个人</option>
							<option value="2" {if  $ad.store_property == 2}selected{/if}>商家</option>
							<option value="3" {if  $ad.store_property == 3}selected{/if}>厂家</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">经营范围：</label>
					<div class="input-group col-sm-4">
						<input type="text" id="business_scope" name="business_scope" value="{$ad.business_scope}"  class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">营业时间：</label>
					<div class="input-group col-sm-4">
						<input id='business_start' name='business_start' value="{$ad.business_start}" onclick="WdatePicker({dateFmt:'HH:mm:00'})" style="width: 190px;"  type='text' placeholder="开始时间" class="form-control layer-date" />
						<input id='business_end' name='business_end' value="{$ad.business_end}" onclick="WdatePicker({dateFmt:'HH:mm:00'})" style="width: 190px;"  type='text' placeholder="结束时间" class="form-control layer-date" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">客服电话：</label>
					<div class="input-group col-sm-4">
						<input type="text" id="service_tel" name="service_tel" value="{$ad.service_tel}"  class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">客服QQ：</label>
					<div class="input-group col-sm-4">
						<input type="text" id="service_qq" name="service_qq" value="{$ad.service_qq}"  class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">客服微信：</label>
					<div class="input-group col-sm-4">
						<input type="text" id="service_Wechat" name="service_Wechat" value="{$ad.service_Wechat}"  class="form-control" />
					</div>
				</div>
				 <!--店铺基本信息end-->
					
				<div class="form-group">
						<div class="col-sm-4 col-sm-offset-3">
							<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>
						</div>
				</div>
				</form>
			</div>
		</div>
	</div>
</div>
<div class="modal-content" id="map-dialog" style="position:fixed;z-index:1000;background:#fff;left: 17%;top: 5%;right: 5%;display: none;">
				<div class="modal-header" style="padding: 5px;"><h4>请选择地点<button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="$('#map-dialog').hide()">×</button></h4></div>
				<div class="modal-body">
					<div class="form-group" style="margin-bottom: 13px;">
						<div class="input-group">
							<input type="text" id="suggestId" class="form-control" placeholder="请输入地址来直接查找相关位置">
							<div class="input-group-btn"><button class="btn btn-default"><i class="icon-search"></i> 搜索</button></div>
						</div>
					</div>
					<div id="searchResultPanel" style="z-index:2;width:300px;height:400px;position:absolute;left:30px;top:50px;"></div>
					<div id="map-container" style="height: 480px; overflow: hidden; position: relative; z-index: 0; background-color: rgb(243, 241, 236); color: rgb(0, 0, 0); text-align: left;">
					</div>
					<div class="modal-footer ">
							<a  class="btn btn-default" data-dismiss="modal" onclick="javascript:$('#map-dialog').hide()">取消</a><a onclick="setJW()"  class="btn btn-primary ">确认</a>
					</div>
				</div>
</div>
{/block} {block name="script"}
<script src="__JS__/jquery.form.js"></script>
<script src="__LIB__/validate/jquery.validate.min.js"></script>
<script src="__LIB__/validate/messages_zh.min.js"></script>
<script src="__LIB__/validate/add_validate.min.js"></script>
<script src="__LIB__/fileinput/js/fileinput.min.js"></script>
<script src="__LIB__/fileinput/js/locales/zh.js"></script>
<script src="__LIB__/datepicker/WdatePicker.js"></script>

<script src="__LIB__/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="__LIB__/ueditor/ueditor.all.js" type="text/javascript"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=grTHl4v1H6uGFLChfz0aB0uQG4XWQv0k"></script>
<script>
	var lng;
	var lat;
	
	function G(id) {
	    return document.getElementById(id);
	}
   var map = new BMap.Map("map-container");
	//map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
	var point = new BMap.Point(113.023083,25.785985);
	map.centerAndZoom(point,12);
	map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
	map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
	
	var marker = new BMap.Marker(point);// 创建标注
	map.addOverlay(marker);    // 将标注添加到地图中
	marker.enableDragging();
	function showInfo(e){
		//alert(e.point.lng + ", " + e.point.lat);
		//var pt=market.getPosition();
		var pt=e.point;
		var geoc = new BMap.Geocoder();    
		geoc.getLocation(pt, function(rs){
			var addComp = rs.addressComponents;
			var address=addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber;
			$("#suggestId").val(address);
			lng=e.point.lng;
			lat=e.point.lat;
		});        
		
	}
	var opts = {
	  offset   : new BMap.Size(60, -60)    //设置文本偏移量
	}
	var label = new BMap.Label("移动红色图标标记位置", opts);  // 创建文本标注对象
		label.setStyle({
			 color : "red",
			 fontSize : "18px",
			 height : "40px",
			 fontWeight:"700",
			 lineHeight : "40px",
			 fontFamily:"微软雅黑"
		 });
	marker.setLabel(label);
	marker.setAnimation(BMAP_ANIMATION_BOUNCE);
	marker.addEventListener("dragend", showInfo);
	map.addEventListener("click", showInfo);
	var size = new BMap.Size(10, 20);
	map.addControl(new BMap.CityListControl({
	    anchor: BMAP_ANCHOR_TOP_LEFT,
	    offset: size,
	    // 切换城市之间事件
	    // onChangeBefore: function(){
	    //    alert('before');
	    // },
	    // 切换城市之后事件
	    // onChangeAfter:function(){
	    //   alert('after');
	    // }
	}));
	var numb=0;
	function show_map(){
		$('#map-dialog').show();
		numb=0;
		setInterval(function(){
			if(numb==0){
				numb=1;
				map.panTo(marker.getPosition());
			}
		},500);
	}
	
	function setJW(){
		$("#longitude").val(lng);
		$("#latitude").val(lat);
		$("#address").val($("#suggestId").val());
		map.panTo(marker.getPosition());
		$('#map-dialog').hide();
	}
	//编辑器
	var ueditor = UE.getEditor('content');
	//顶部导航
	$("#li-bar-index").addClass("active");
	upload_one('{$ad.store_logo}');
	$(function() {
		$("#myForm").validate({
			rules: {
				store_name: "required",
				address: "required"
			},
			messages: {
				store_name: ICON.error + "请输入名称",
				address: ICON.error + "请输入地址"
			},
			submitHandler: function(form) {
				ajaxForm();
			}
		});
	});
</script>
{/block}